package com.czy.owner.api;

import android.text.TextUtils;

import com.czy.owner.net.api.BaseApi;
import com.czy.owner.net.listener.HttpOnNextListener;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

import java.util.HashMap;

import retrofit2.Retrofit;
import rx.Observable;

/**
 * Created by asus on 2017/5/26.
 */

public class GoodsDetailApi extends BaseApi {
    private String session;
    private String goodsId;
    private String specGroupKey;
    private String storeId;

    public String getSpecGroupKey() {
        return specGroupKey;
    }

    public void setSpecGroupKey(String specGroupKey) {
        this.specGroupKey = specGroupKey;
    }

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getStoreId() {
        return storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    public GoodsDetailApi(HttpOnNextListener listener, RxAppCompatActivity rxAppCompatActivity) {
        super(listener, rxAppCompatActivity);
        setShowProgress(true);
        setCache(true);
        setCookieNetWorkTime(0);
    }

    public String getSession() {
        return session;
    }

    public void setSession(String session) {
        this.session = session;
    }


    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpPostService service = retrofit.create(HttpPostService.class);
        HashMap<String, Object> map = new HashMap<>();
        if (!TextUtils.isEmpty(getSession())) {
            map.put("session", getSession());
        }
        if (!TextUtils.isEmpty(getGoodsId())){
            map.put("goodsId", getGoodsId());
        }
        if (!TextUtils.isEmpty(getSpecGroupKey())){
            map.put("specGroupKey", getSpecGroupKey());
        }
        if (!TextUtils.isEmpty(getStoreId())){
            map.put("storeId", getStoreId());
        }
        return service.getGoodsDetailApi(map);
    }
}
